package class2;

public class TestDemo {
    public static void main(String[] args) {
        int[] arr = {1, 2, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9};
        int target = 2;
        int index = findLNumber(arr, target);
        System.out.println("index = " + index);
    }

    // 普通二分查找
    public static int findLNumber(int[] arr, int target) {
        int L = 0, R = arr.length - 1;
        int ans = -1;
        while (L <= R) {
            int mid = L + ((R - L) >> 1);
            if (arr[mid] >= target) {
                ans = mid;
                R = mid - 1;
            } else {
                L = mid + 1;
            }
        }
        return ans;
    }

}
